//
// Decompiled by Jadx - 756ms
//
package de;

import android.app.Activity;
import dt.b;
import f.a;
import f.c;
import f.d;
import fi.y;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.net.IDN;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Locale;
import java.util.logging.Logger;
import kotlin.jvm.internal.i;
import kotlin.text.m;
import kotlin.text.q;
import okhttp3.af;
import z.f;

public class aa implements e, b {
    public static aa ac;
    public static int ae;
    public static int af;
    public static int ag;
    public static int ah;
    public static final aa ad = new aa();
    public static final int[] ai = {-2113666366, -2113666365, -2113666364, -2113666363, -2113666362, -2113666361, -2113666360};
    public static final int[] aj = {-2113666908, -2113666647, -2113666240};
    public static final int[] ak = {-2113667072, -2113667071};
    public static final int[] al = {-2113666980, -2113666979, -2113666833, -2113666832, -2113666831, -2113666830, -2113666272, -2113666248};

    public static String am(String str) {
        StringBuilder sb;
        bg(str);
        Calendar calendar = Calendar.getInstance();
        int i = calendar.get(1);
        int i2 = calendar.get(2) + 1;
        int i3 = calendar.get(5);
        int i4 = i - af;
        int i5 = i2 - ag;
        int i6 = i3 - ah;
        ae = i4;
        if (i4 <= 0) {
            ae = 0;
            sb = new StringBuilder();
        } else {
            if (i5 < 0 || (i5 == 0 && i6 < 0)) {
                ae = i4 - 1;
            }
            sb = new StringBuilder();
        }
        sb.append(String.valueOf(ae));
        sb.append("岁!");
        return sb.toString();
    }

    public static int an(String str) {
        bg(str);
        Calendar calendar = Calendar.getInstance();
        int i = calendar.get(1);
        int i2 = calendar.get(2) + 1;
        int i3 = calendar.get(5);
        int i4 = i - af;
        int i5 = i2 - ag;
        int i6 = i3 - ah;
        ae = i4;
        if (i4 <= 0) {
            return 0;
        }
        if (i5 < 0 || (i5 == 0 && i6 < 0)) {
            ae = i4 - 1;
        }
        return ae;
    }

    public static void ao(Activity activity) {
        String[] stringArray = activity.getResources().getStringArray(-2113732608);
        StringBuilder sb = new StringBuilder();
        for (String str : stringArray) {
            ax("am force-stop " + str);
            sb.append(str);
            sb.append("->已执行\n");
        }
        y.b(activity, "执行结果", sb.toString());
    }

    public static String ap(Object obj) {
        String str;
        if (obj == null) {
            return "null";
        }
        if (obj instanceof CharSequence) {
            StringBuilder sb = new StringBuilder("\"");
            String obj2 = obj.toString();
            int length = obj2.length();
            StringBuilder sb2 = new StringBuilder(length);
            int i = 0;
            while (i < length) {
                int codePointAt = obj2.codePointAt(i);
                int type = Character.getType(codePointAt);
                if (type != 0 && type != 15 && type != 16 && type != 18 && type != 19) {
                    sb2.append(Character.toChars(codePointAt));
                } else {
                    switch (codePointAt) {
                        case 8:
                            str = "\\b";
                            break;
                        case 9:
                            str = "\\t";
                            break;
                        case 10:
                            str = "\\n";
                            break;
                        case 11:
                        default:
                            sb2.append("\\u");
                            str = String.format("%04x", Integer.valueOf(codePointAt)).toUpperCase(Locale.US);
                            break;
                        case 12:
                            str = "\\f";
                            break;
                        case 13:
                            str = "\\r";
                            break;
                    }
                    sb2.append(str);
                }
                i += Character.charCount(codePointAt);
            }
            sb.append(sb2.toString());
            sb.append('\"');
            return sb.toString();
        }
        Class<?> cls = obj.getClass();
        if (Byte.class == cls) {
            return at((Byte) obj);
        }
        if (cls.isArray()) {
            Class<?> componentType = cls.getComponentType();
            if (Byte.TYPE == componentType) {
                byte[] bArr = (byte[]) obj;
                StringBuilder sb3 = new StringBuilder("[");
                for (int i2 = 0; i2 < bArr.length; i2++) {
                    if (i2 > 0) {
                        sb3.append(", ");
                    }
                    sb3.append(at(Byte.valueOf(bArr[i2])));
                }
                sb3.append(']');
                return sb3.toString();
            }
            if (Short.TYPE == componentType) {
                return Arrays.toString((short[]) obj);
            }
            if (Character.TYPE == componentType) {
                return Arrays.toString((char[]) obj);
            }
            if (Integer.TYPE == componentType) {
                return Arrays.toString((int[]) obj);
            }
            if (Long.TYPE == componentType) {
                return Arrays.toString((long[]) obj);
            }
            if (Float.TYPE == componentType) {
                return Arrays.toString((float[]) obj);
            }
            if (Double.TYPE == componentType) {
                return Arrays.toString((double[]) obj);
            }
            if (Boolean.TYPE == componentType) {
                return Arrays.toString((boolean[]) obj);
            }
            StringBuilder sb4 = new StringBuilder();
            as((Object[]) obj, sb4, new HashSet());
            return sb4.toString();
        }
        return obj.toString();
    }

    public static final void aq(a aVar, c cVar, String str) {
        d.c.getClass();
        Logger logger = d.b;
        StringBuilder sb = new StringBuilder();
        sb.append(cVar.f);
        sb.append(' ');
        String format = String.format("%-22s", Arrays.copyOf(new Object[]{str}, 1));
        i.e(format, "java.lang.String.format(format, *args)");
        sb.append(format);
        sb.append(": ");
        sb.append(aVar.e);
        logger.fine(sb.toString());
    }

    public static final void ar(StringBuilder sb, Object obj, ey.a aVar) {
        CharSequence valueOf;
        if (aVar != null) {
            obj = aVar.invoke(obj);
        } else {
            if (!(obj == null ? true : obj instanceof CharSequence)) {
                if (obj instanceof Character) {
                    sb.append(((Character) obj).charValue());
                    return;
                } else {
                    valueOf = String.valueOf(obj);
                    sb.append(valueOf);
                }
            }
        }
        valueOf = (CharSequence) obj;
        sb.append(valueOf);
    }

    public static void as(Object[] objArr, StringBuilder sb, HashSet hashSet) {
        String ap;
        if (objArr == null) {
            sb.append("null");
            return;
        }
        hashSet.add(objArr);
        sb.append('[');
        for (int i = 0; i < objArr.length; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            Object obj = objArr[i];
            if (obj == null) {
                sb.append("null");
            } else {
                Class<?> cls = obj.getClass();
                if (cls.isArray() && cls.getComponentType() == Object.class) {
                    Object[] objArr2 = (Object[]) obj;
                    if (hashSet.contains(objArr2)) {
                        ap = "[...]";
                    } else {
                        as(objArr2, sb, hashSet);
                    }
                } else {
                    ap = ap(obj);
                }
                sb.append(ap);
            }
        }
        sb.append(']');
        hashSet.remove(objArr);
    }

    public static String at(Byte b) {
        if (b == null) {
            return "null";
        }
        return "0x" + String.format("%02x", b).toUpperCase(Locale.US);
    }

    public static final void au(int i) {
        boolean z;
        ez.c cVar = new ez.c(2, 36);
        if (2 <= i && i <= ((ez.a) cVar).b) {
            z = true;
        } else {
            z = false;
        }
        if (z) {
            return;
        }
        StringBuilder l = androidx.activity.b.l("radix ", i, " was not in valid range ");
        l.append(new ez.c(2, 36));
        throw new IllegalArgumentException(l.toString());
    }

    /* JADX WARN: Code restructure failed: missing block: B:24:0x00de, code lost:
    
        return null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:54:0x0050, code lost:
    
        r0 = r4;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:15:0x00b0  */
    /* JADX WARN: Type inference failed for: r15v0 */
    /* JADX WARN: Type inference failed for: r15v1, types: [int] */
    /* JADX WARN: Type inference failed for: r15v5 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final InetAddress av(String str, int i, int i2) {
        int i3;
        boolean z;
        int i4;
        int i5;
        int i6 = 16;
        byte[] bArr = new byte[16];
        boolean z2 = false;
        int i7 = -1;
        int i8 = i;
        int i9 = 0;
        int i10 = -1;
        int i11 = -1;
        while (true) {
            if (i8 < i2) {
                if (i9 == i6) {
                    return null;
                }
                int i12 = i8 + 2;
                if (i12 <= i2 && m.j(str, "::", i8, z2)) {
                    if (i10 != i7) {
                        return null;
                    }
                    i9 += 2;
                    if (i12 == i2) {
                        i3 = i6;
                        i10 = i9;
                        break;
                    }
                    i10 = i9;
                    i11 = i12;
                    i8 = i11;
                    int i13 = 0;
                    while (i8 < i2) {
                    }
                    i5 = i8 - i11;
                    if (i5 == 0) {
                        break;
                    }
                    break;
                }
                if (i9 != 0) {
                    if (m.j(str, ":", i8, z2)) {
                        i8++;
                    } else {
                        if (!m.j(str, ".", i8, z2)) {
                            return null;
                        }
                        int i14 = i9 - 2;
                        int i15 = i14;
                        loop2: while (true) {
                            if (i11 < i2) {
                                if (i15 == i6) {
                                    break;
                                }
                                if (i15 != i14) {
                                    if (str.charAt(i11) != '.') {
                                        break;
                                    }
                                    i11++;
                                }
                                ?? r15 = z2;
                                int i16 = i11;
                                while (i16 < i2) {
                                    char charAt = str.charAt(i16);
                                    if (i.h(charAt, 48) < 0 || i.h(charAt, 57) > 0) {
                                        break;
                                    }
                                    if ((r15 == 0 && i11 != i16) || (i4 = ((r15 * 10) + charAt) - 48) > 255) {
                                        break loop2;
                                    }
                                    i16++;
                                    r15 = i4;
                                }
                                if (i16 - i11 == 0) {
                                    break;
                                }
                                bArr[i15] = (byte) r15;
                                i15++;
                                i11 = i16;
                                i6 = 16;
                                z2 = false;
                            } else if (i15 == i14 + 4) {
                                z = true;
                            }
                        }
                        z = false;
                        if (!z) {
                            return null;
                        }
                        i9 += 2;
                        i3 = 16;
                    }
                }
                i11 = i8;
                i8 = i11;
                int i132 = 0;
                while (i8 < i2) {
                    int x = l.c.x(str.charAt(i8));
                    if (x == -1) {
                        break;
                    }
                    i132 = (i132 << 4) + x;
                    i8++;
                }
                i5 = i8 - i11;
                if (i5 == 0 || i5 > 4) {
                    break;
                }
                int i17 = i9 + 1;
                bArr[i9] = (byte) ((i132 >>> 8) & 255);
                i9 = i17 + 1;
                bArr[i17] = (byte) (i132 & 255);
                i6 = 16;
                z2 = false;
                i7 = -1;
            } else {
                i3 = i6;
                break;
            }
        }
        if (i9 != i3) {
            if (i10 == -1) {
                return null;
            }
            int i18 = i9 - i10;
            System.arraycopy(bArr, i10, bArr, 16 - i18, i18);
            Arrays.fill(bArr, i10, (16 - i9) + i10, (byte) 0);
        }
        return InetAddress.getByAddress(bArr);
    }

    public static final boolean aw(char c, char c2, boolean z) {
        if (c == c2) {
            return true;
        }
        if (!z) {
            return false;
        }
        char upperCase = Character.toUpperCase(c);
        char upperCase2 = Character.toUpperCase(c2);
        return upperCase == upperCase2 || Character.toLowerCase(upperCase) == Character.toLowerCase(upperCase2);
    }

    /* JADX WARN: Code restructure failed: missing block: B:19:0x0052, code lost:
    
        r6 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:20:0x0053, code lost:
    
        r6.printStackTrace();
     */
    /* JADX WARN: Code restructure failed: missing block: B:21:0x0056, code lost:
    
        return;
     */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0083 A[Catch: IOException -> 0x007f, TryCatch #12 {IOException -> 0x007f, blocks: (B:41:0x007b, B:30:0x0083, B:32:0x0088), top: B:40:0x007b }] */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0088 A[Catch: IOException -> 0x007f, TRY_LEAVE, TryCatch #12 {IOException -> 0x007f, blocks: (B:41:0x007b, B:30:0x0083, B:32:0x0088), top: B:40:0x007b }] */
    /* JADX WARN: Removed duplicated region for block: B:39:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:40:0x007b A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:48:0x009d A[Catch: IOException -> 0x0099, TryCatch #0 {IOException -> 0x0099, blocks: (B:57:0x0095, B:48:0x009d, B:50:0x00a2), top: B:56:0x0095 }] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x00a2 A[Catch: IOException -> 0x0099, TRY_LEAVE, TryCatch #0 {IOException -> 0x0099, blocks: (B:57:0x0095, B:48:0x009d, B:50:0x00a2), top: B:56:0x0095 }] */
    /* JADX WARN: Removed duplicated region for block: B:56:0x0095 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void ax(String str) {
        Process process;
        BufferedReader bufferedReader;
        DataOutputStream dataOutputStream;
        DataOutputStream dataOutputStream2 = null;
        try {
            process = Runtime.getRuntime().exec("su");
            try {
                dataOutputStream = new DataOutputStream(process.getOutputStream());
            } catch (IOException e) {
                e = e;
                bufferedReader = null;
                try {
                    e.printStackTrace();
                    if (dataOutputStream2 != null) {
                        try {
                            dataOutputStream2.close();
                        } catch (IOException e2) {
                            e2.printStackTrace();
                            return;
                        }
                    }
                    if (bufferedReader != null) {
                        bufferedReader.close();
                    }
                    if (process == null) {
                        process.destroy();
                        return;
                    }
                    return;
                } catch (Throwable th) {
                    th = th;
                    dataOutputStream = dataOutputStream2;
                    dataOutputStream2 = dataOutputStream;
                    if (dataOutputStream2 != null) {
                        try {
                            dataOutputStream2.close();
                        } catch (IOException e3) {
                            e3.printStackTrace();
                            throw th;
                        }
                    }
                    if (bufferedReader != null) {
                        bufferedReader.close();
                    }
                    if (process != null) {
                        process.destroy();
                    }
                    throw th;
                }
            } catch (InterruptedException e4) {
                e = e4;
                bufferedReader = null;
                e.printStackTrace();
                if (dataOutputStream2 != null) {
                }
                if (bufferedReader != null) {
                }
                if (process == null) {
                }
            } catch (Throwable th2) {
                th = th2;
                bufferedReader = null;
                if (dataOutputStream2 != null) {
                }
                if (bufferedReader != null) {
                }
                if (process != null) {
                }
                throw th;
            }
        } catch (IOException e5) {
            e = e5;
            process = null;
            bufferedReader = null;
            e.printStackTrace();
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process == null) {
            }
        } catch (InterruptedException e6) {
            e = e6;
            process = null;
            bufferedReader = null;
            e.printStackTrace();
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process == null) {
            }
        } catch (Throwable th3) {
            th = th3;
            process = null;
            bufferedReader = null;
        }
        try {
            bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        } catch (IOException e7) {
            e = e7;
            bufferedReader = null;
            dataOutputStream2 = dataOutputStream;
            e.printStackTrace();
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process == null) {
            }
        } catch (InterruptedException e8) {
            e = e8;
            bufferedReader = null;
            dataOutputStream2 = dataOutputStream;
            e.printStackTrace();
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process == null) {
            }
        } catch (Throwable th4) {
            th = th4;
            bufferedReader = null;
        }
        try {
            dataOutputStream.writeBytes(str + "\n");
            dataOutputStream.writeBytes("exit\n");
            dataOutputStream.flush();
            process.waitFor();
            do {
            } while (bufferedReader.readLine() != null);
            dataOutputStream.close();
            bufferedReader.close();
            process.destroy();
        } catch (IOException e9) {
            e = e9;
            dataOutputStream2 = dataOutputStream;
            e.printStackTrace();
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process == null) {
            }
        } catch (InterruptedException e10) {
            e = e10;
            dataOutputStream2 = dataOutputStream;
            e.printStackTrace();
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process == null) {
            }
        } catch (Throwable th5) {
            th = th5;
            dataOutputStream2 = dataOutputStream;
            if (dataOutputStream2 != null) {
            }
            if (bufferedReader != null) {
            }
            if (process != null) {
            }
            throw th;
        }
    }

    public static Type ay(Class cls) {
        ArrayList arrayList;
        Type genericSuperclass = cls.getGenericSuperclass();
        if (genericSuperclass instanceof ParameterizedType) {
            arrayList = new ArrayList();
            for (Type type : ((ParameterizedType) genericSuperclass).getActualTypeArguments()) {
                arrayList.add(type);
                if (type instanceof ParameterizedType) {
                    Collections.addAll(arrayList, ((ParameterizedType) type).getActualTypeArguments());
                }
            }
        } else {
            arrayList = null;
        }
        if (arrayList != null && !arrayList.isEmpty()) {
            return (Type) arrayList.get(0);
        }
        return af.class;
    }

    public static final String az(long j) {
        StringBuilder sb;
        long j2;
        long j3;
        long j4;
        if (j > -999500000) {
            if (j > -999500) {
                if (j <= 0) {
                    sb = new StringBuilder();
                    j4 = j - 500;
                } else if (j < 999500) {
                    sb = new StringBuilder();
                    j4 = j + 500;
                } else if (j < 0x3b9328e0) {
                    sb = new StringBuilder();
                    j3 = j + 500000;
                } else {
                    sb = new StringBuilder();
                    j2 = j + 0x1dcd6500;
                }
                sb.append(j4 / 1000);
                sb.append(" µs");
                String format = String.format("%6s", Arrays.copyOf(new Object[]{sb.toString()}, 1));
                i.e(format, "java.lang.String.format(format, *args)");
                return format;
            }
            sb = new StringBuilder();
            j3 = j - 500000;
            sb.append(j3 / 1000000);
            sb.append(" ms");
            String format2 = String.format("%6s", Arrays.copyOf(new Object[]{sb.toString()}, 1));
            i.e(format2, "java.lang.String.format(format, *args)");
            return format2;
        }
        sb = new StringBuilder();
        j2 = j - 0x1dcd6500;
        sb.append(j2 / 0x3b9aca00);
        sb.append(" s ");
        String format22 = String.format("%6s", Arrays.copyOf(new Object[]{sb.toString()}, 1));
        i.e(format22, "java.lang.String.format(format, *args)");
        return format22;
    }

    public static Class ba(Type type) {
        if (type instanceof ParameterizedType) {
            Type type2 = ((ParameterizedType) type).getActualTypeArguments()[0];
            if (type2 instanceof ParameterizedType) {
                type2 = ((ParameterizedType) type2).getRawType();
            } else if (type2 instanceof GenericArrayType) {
                type2 = ((GenericArrayType) type2).getGenericComponentType();
            } else if (type2 instanceof TypeVariable) {
                return ba(((TypeVariable) type2).getBounds()[0]);
            }
            return (Class) type2;
        }
        if (type instanceof TypeVariable) {
            return ba(((TypeVariable) type).getBounds()[0]);
        }
        return (Class) type;
    }

    public static Type bb(ParameterizedType parameterizedType) {
        Type type = parameterizedType.getActualTypeArguments()[0];
        return type instanceof ParameterizedType ? ((ParameterizedType) type).getRawType() : type instanceof GenericArrayType ? ((GenericArrayType) type).getGenericComponentType() : type instanceof TypeVariable ? ba(((TypeVariable) type).getBounds()[0]) : type;
    }

    public static Type bc(Type type) {
        return type instanceof ParameterizedType ? ((ParameterizedType) type).getActualTypeArguments()[0] : type instanceof TypeVariable ? bd(((TypeVariable) type).getBounds()[0]) : type;
    }

    public static Type bd(Type type) {
        return type instanceof ParameterizedType ? bb((ParameterizedType) type) : type instanceof TypeVariable ? bd(((TypeVariable) type).getBounds()[0]) : type;
    }

    public static final boolean be(char c) {
        return Character.isWhitespace(c) || Character.isSpaceChar(c);
    }

    public static final int bf(z.y yVar, int i) {
        int i2;
        i.f(yVar, "$this$segment");
        int[] directory$okio = yVar.getDirectory$okio();
        int i3 = i + 1;
        int length = yVar.getSegments$okio().length;
        i.f(directory$okio, "$this$binarySearch");
        int i4 = length - 1;
        int i5 = 0;
        while (true) {
            if (i5 <= i4) {
                i2 = (i5 + i4) >>> 1;
                int i6 = directory$okio[i2];
                if (i6 < i3) {
                    i5 = i2 + 1;
                } else {
                    if (i6 <= i3) {
                        break;
                    }
                    i4 = i2 - 1;
                }
            } else {
                i2 = (-i5) - 1;
                break;
            }
        }
        if (i2 < 0) {
            return ~i2;
        }
        return i2;
    }

    public static void bg(String str) {
        Date date;
        try {
            Calendar calendar = Calendar.getInstance();
            try {
                date = new SimpleDateFormat("yyyy-MM-dd").parse(str);
            } catch (Exception unused) {
                date = null;
            }
            calendar.setTime(date);
            if (date != null) {
                af = calendar.get(1);
                ag = calendar.get(2) + 1;
                ah = calendar.get(5);
            }
        } catch (Exception unused2) {
        }
    }

    public static final String bh(String str) {
        boolean z;
        InetAddress av;
        i.f(str, "$this$toCanonicalHost");
        int i = 0;
        int i2 = -1;
        if (q.l(str, ":", false)) {
            if (m.k(str, "[", false) && str.endsWith("]")) {
                av = av(str, 1, str.length() - 1);
            } else {
                av = av(str, 0, str.length());
            }
            if (av == null) {
                return null;
            }
            byte[] address = av.getAddress();
            if (address.length == 16) {
                int i3 = 0;
                int i4 = 0;
                while (i3 < address.length) {
                    int i5 = i3;
                    while (i5 < 16 && address[i5] == 0 && address[i5 + 1] == 0) {
                        i5 += 2;
                    }
                    int i6 = i5 - i3;
                    if (i6 > i4 && i6 >= 4) {
                        i2 = i3;
                        i4 = i6;
                    }
                    i3 = i5 + 2;
                }
                f fVar = new f();
                while (i < address.length) {
                    if (i == i2) {
                        fVar.ai(58);
                        i += i4;
                        if (i == 16) {
                            fVar.ai(58);
                        }
                    } else {
                        if (i > 0) {
                            fVar.ai(58);
                        }
                        byte b = address[i];
                        byte[] bArr = l.c.a;
                        fVar.ak(((b & 255) << 8) | (address[i + 1] & 255));
                        i += 2;
                    }
                }
                return fVar.ae();
            }
            if (address.length == 4) {
                return av.getHostAddress();
            }
            throw new AssertionError("Invalid IPv6 address: '" + str + '\'');
        }
        try {
            String ascii = IDN.toASCII(str);
            i.e(ascii, "IDN.toASCII(host)");
            Locale locale = Locale.US;
            i.e(locale, "Locale.US");
            String lowerCase = ascii.toLowerCase(locale);
            i.e(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
            if (lowerCase.length() == 0) {
                z = true;
            } else {
                z = false;
            }
            if (z) {
                return null;
            }
            int length = lowerCase.length();
            for (int i7 = 0; i7 < length; i7++) {
                char charAt = lowerCase.charAt(i7);
                if (i.h(charAt, 31) > 0 && i.h(charAt, 127) < 0 && q.p(" #%/:?@[\\]", charAt, 0, false, 6) == -1) {
                }
                i = 1;
                break;
            }
            if (i != 0) {
                return null;
            }
            return lowerCase;
        } catch (IllegalArgumentException unused) {
            return null;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public Object bi(FileInputStream fileInputStream, Type type) {
        ObjectInputStream objectInputStream;
        Object obj = null;
        try {
            try {
                objectInputStream = new ObjectInputStream(fileInputStream);
                try {
                    obj = objectInputStream.readObject();
                    ed.d.h(new Closeable[]{objectInputStream});
                } catch (IOException e) {
                    e = e;
                    e.printStackTrace();
                    ed.d.h(new Closeable[]{objectInputStream});
                    return obj;
                } catch (ClassNotFoundException e2) {
                    e = e2;
                    e.printStackTrace();
                    ed.d.h(new Closeable[]{objectInputStream});
                    return obj;
                }
            } catch (Throwable th) {
                th = th;
                obj = objectInputStream;
                ed.d.h(new Closeable[]{obj});
                throw th;
            }
        } catch (IOException e3) {
            e = e3;
            objectInputStream = null;
            e.printStackTrace();
            ed.d.h(new Closeable[]{objectInputStream});
            return obj;
        } catch (ClassNotFoundException e4) {
            e = e4;
            objectInputStream = null;
            e.printStackTrace();
            ed.d.h(new Closeable[]{objectInputStream});
            return obj;
        } catch (Throwable th2) {
            th = th2;
            ed.d.h(new Closeable[]{obj});
            throw th;
        }
        return obj;
    }

    public boolean bj(Object obj, OutputStream outputStream) {
        ObjectOutputStream objectOutputStream;
        ObjectOutputStream objectOutputStream2 = null;
        try {
            try {
                objectOutputStream = new ObjectOutputStream(outputStream);
            } catch (Throwable th) {
                th = th;
                objectOutputStream = null;
            }
        } catch (IOException e) {
            e = e;
        }
        try {
            objectOutputStream.writeObject(obj);
            objectOutputStream.flush();
            ed.d.h(new Closeable[]{objectOutputStream});
            return true;
        } catch (IOException e2) {
            e = e2;
            objectOutputStream2 = objectOutputStream;
            e.printStackTrace();
            ed.d.h(new Closeable[]{objectOutputStream2});
            return false;
        } catch (Throwable th2) {
            th = th2;
            ed.d.h(new Closeable[]{objectOutputStream});
            throw th;
        }
    }
}
